package com.mtiiot.fsmanage.controller;

import com.mtiiot.fsmanage.server.EmailServer;
import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by Administrator on 16-8-23.
 */
@Controller
public class EmailController {

    @Autowired
    EmailServer emailServer;

    /**
     * 查询email数据
     *
     */
    @RequestMapping(value="/email/emailQuery.action",produces="application/json;charset=UTF-8")
    @ResponseBody
    public Object emailQuery(String sysName,String l1Name,String l2Name,String l3Name,String times,String queryKeyWord,int count,String sort)throws Exception{
        Object obj=emailServer.emailQuery(sysName, l1Name, l2Name, l3Name, times, queryKeyWord, count, sort);
        ObjectMapper mapper = new ObjectMapper();
        String jsonStr=mapper.writeValueAsString(obj);
        return jsonStr;
    }

    /**
     * 查询email数据
     */
    @RequestMapping(value="/email/emailStatistics.action",produces="application/json;charset=UTF-8")
    @ResponseBody
    public Object emailStatistics(String sysName,String l1Name,String l2Name,String l3Name,String times) throws Exception {
        Object obj=emailServer.emailStatistics(sysName, l1Name, l2Name, l3Name, times);
        ObjectMapper mapper = new ObjectMapper();
        String jsonStr=mapper.writeValueAsString(obj);
        System.out.println(jsonStr);
        return jsonStr;
    }
}
